<?php
class SystemAction extends BackAction{
    public $server_url;
    public $key;
    public $topdomain;
    public $dirtype;
    public function _initialize() {
        parent::_initialize();
        $this->server_url=trim(C('server_url'));
        if (!$this->server_url){
            $this->server_url='http://up.yunweicms.com/';
	    }
        $this->key=trim(C('server_key'));
        $this->topdomain=trim(C('server_topdomain'));
        if (!$this->topdomain){
            $this->topdomain=$this->getTopDomain();
        }
        if (file_exists($_SERVER['DOCUMENT_ROOT'].'/Lib')&&is_dir($_SERVER['DOCUMENT_ROOT'].'/Lib')){
            $this->dirtype=2;
        }else {
            $this->dirtype=1;
        }
        $p107 = new Model();
        $p107->query('CREATE TABLE IF NOT EXISTS `'.C(DB_PREFIX).'system_info` (`lastsqlupdate` INT( 10 ) NOT NULL ,`version` VARCHAR( 10 ) NOT NULL) ENGINE = MYISAM CHARACTER SET utf8');
        $p107->query('CREATE TABLE IF NOT EXISTS `'.C(DB_PREFIX)."update_record` ( `id` int(11) NOT NULL AUTO_INCREMENT, `msg` varchar(600) NOT NULL DEFAULT '', `type` varchar(20) NOT NULL DEFAULT '', `time` int(10) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MYISAM DEFAULT CHARSET=utf8");
        $p108=M('Node')->where(array('name'=>'Function','title'=>'功能模块'))->find();
        $p109=M('Node')->where(array('name'=>'aboutus'))->find();
        if (!$p109){
            $p110=array( 'name'=>'Aboutus', 'title'=>'关于我们', 'status'=>1, 'remark'=>'0', 'pid'=>$p108['id'], 'level'=>2, 'sort'=>0, 'display'=>2 );
            M('Node')->add($p110);
        }
        $p111=M('Node')->where(array('title'=>'站点设置'))->find();
		$p112=M('Node')->where(array('title'=>'平台支付配置'))->find();
		if (!$p112){ 
			$p113=array( 'name'=>'platform', 'title'=>'平台支付配置', 'status'=>1, 'remark'=>'', 'pid'=>$p111['id'], 'level'=>3, 'sort'=>0, 'display'=>2 );
			M('Node')->add($p113); 
		} 
		$p114=M('Node')->where(array('title'=>'扩展管理'))->find();
		$p115=M('Node')->where(array('title'=>'平台支付'))->find();
	    if (!$p115){ 
			$p113=array( 'name'=>'Platform', 'title'=>'平台支付', 'status'=>1, 'remark'=>'', 'pid'=>$p114['id'], 'level'=>2, 'sort'=>0, 'display'=>2 );
			$p116=M('Node')->add($p113);
            $p113=array( 'name'=>'index', 'title'=>'平台对账','status'=>1, 'remark'=>'', 'pid'=>$p116, 'level'=>3, 'sort'=>0, 'display'=>2 );
			M('Node')->add($p113); 
		} 
	} 
	public function index(){ 
		$p117['display']=1; 
		$p117['status']=1;
		$p118['sort']='asc';
		$p119=M('node')->where($p117)->order($p118)->select(); 
		$this->assign('nav',$p119); 
		$this->display(); 
	}
    public function closeAD(){ 
		if(IS_GET){ 
			$p120 = $this->_get('id','intval');
			if($p120){ 
				M('notice_record')->add(array('n_id'=>$p120,'userid'=>$_SESSION['userid'])); 
			} 
		} 
	} 
	public function menu(){ 
		if(empty($_GET['pid'])){
			$p117['display']=2;
			$p117['status']=1; 
			$p117['pid']=2; 
			$p117['level']=2; 
			$p118['sort']='asc';
			$p119=M('node')->where($p117)->order($p118)->select();
			$this->assign('nav',$p119);
		} 
		$this->display();
	} 
	public function main(){ 
			$p121 = './YunweiData/conf/version.php';
			$p122 = include($p121); 
			$p122 = $p122['ver'];
			$p123= urlencode("http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]); 
			$p124 = "http://up.yunweicms.com/update.php";
			$p125 = $p124."?a=client_check_time&v=".$p122."&u=".$p123;
			$p126 = file_get_contents($p125);
			if($p126=='0'){ 
				$p126='[您的域名未授权，请联系云微CMS官方客服QQ:507642401]';
			}else{ 
				$p126="(".date(Y-m-d,$p126).")"; 
			}	
			$this->assign("ver",$p122); 
			$this->assign('domain_time',$p126);
			$this->display(); 
	}
	
    public function repairTable(){ 
		$p107 = new Model();
        error_reporting(0); 
		@mysql_query('REPAIR TABLE `'.C(DB_PREFIX).'behavior`'); 
		@mysql_query('REPAIR TABLE `'.C(DB_PREFIX).'requestdata`');
		$this->success('成功删除缓存',U('System/main'));
	} 
	
	function curlGet($p127){ 
		$p128 = curl_init();
		$p129= 'Accept-Charset: utf-8'; 
		curl_setopt($p128, CURLOPT_URL, $p127);
		curl_setopt($p128, CURLOPT_CUSTOMREQUEST, GET); 
		curl_setopt($p128, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($p128, CURLOPT_SSL_VERIFYHOST, FALSE);
		curl_setopt($p130, CURLOPT_HTTPHEADER, $p133);
		curl_setopt($p128, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
		curl_setopt($p128, CURLOPT_FOLLOWLOCATION, 1); 
		curl_setopt($p128, CURLOPT_AUTOREFERER, 1); 
		curl_setopt($p128, CURLOPT_POSTFIELDS, $p131);
		curl_setopt($p128, CURLOPT_RETURNTRANSFER, true);
		$p132 = curl_exec($p128);
		return $p132;
	}

}


?>
